**Run regressions**
clear
use "Results\tab_A3\regression_sample.dta"

merge 1:1 final_educ using "Results\fig_A1\final_educ_hours_moments_standardized.dta"

drop if _merge == 2
drop _merge

merge 1:1 final_educ using "Results\tab_A3\final_educ_lifetime_earnings_moments_standardized.dta"

drop if _merge == 2
drop _merge

label var goldin_quotient "inflexibility"
label var wage_start_mean_ambition_s "starting wage"
label var wage_growth_ambition_s "growth"
label var short_hours_50_s "share short hours"
label var irreg_50_s "share irregular hours"
label var p_life_earnings_s "lifetime earnings"

label var ever_top_manager "manager"
label var avr_participation "participation"
label var avr_ft_if_par "full-time"
label var age_at_first_kid "first child"
label var age_at_first_kid_women "women first child"

gen wealth_50_mil=wealth_50/1000000
label var wealth_50_mil "wealth at age 50"


replace age_at_first_kid = . if age_at_first_kid > 45
replace age_at_first_kid_women = . if age_at_first_kid_women > 45



foreach outcome in goldin_quotient ever_top_manager avr_participation avr_ft_if_par age_at_first_kid age_at_first_kid_women wealth_50_mil {

*** mean of dependent variable
sum `outcome' [aweight=educ_count] if !missing(final_field_num)
local mean_dep=r(mean)

*** col (0) None
reghdfe `outcome' wage_start_mean_ambition_s wage_growth_ambition_s [aweight=educ_count] if !missing(final_field_num), vce(robust)
outreg2 using "Results\tab_A3\Table_worklife_`outcome'.tex", replace label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("none")

*** col (1) education level FE
reghdfe `outcome' wage_start_mean_ambition_s wage_growth_ambition_s [aweight=educ_count] if !missing(final_field_num), vce(robust) a(final_educ_level_4) 
outreg2 using "Results\tab_A3\Table_worklife_`outcome'.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("lvlFE")
outreg2 using "Results\tab_A3\Table_worklife_draft.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("lvlFE")

*** col (2) education field FE
reghdfe `outcome' wage_start_mean_ambition_s wage_growth_ambition_s [aweight=educ_count] if !missing(final_field_num), vce(robust) a(final_field_num)
outreg2 using "Results\tab_A3\Table_worklife_`outcome'.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("fieldFE")
outreg2 using "Results\tab_A3\Table_worklife_draft.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("fieldFE")

*** col (3) education level FE + lifetime earnings control
reghdfe `outcome' wage_start_mean_ambition_s wage_growth_ambition_s p_life_earnings_s [aweight=educ_count] if !missing(final_field_num), vce(robust) a(final_educ_level_4)
outreg2 using "Results\tab_A3\Table_worklife_`outcome'.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("lvlFE")
outreg2 using "Results\tab_A3\Table_worklife_draft.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("lvlFE")

*** col (4) education level FE + hours controls
reghdfe `outcome' wage_start_mean_ambition_s wage_growth_ambition_s short_hours_50_s irreg_50_s [aweight=educ_count] if !missing(final_field_num), vce(robust) a(final_educ_level_4)
outreg2 using "Results\tab_A3\Table_worklife_`outcome'.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("lvlFE")
outreg2 using "Results\tab_A3\Table_worklife_draft.tex", append label nocons addstat("Mean", `mean_dep') adjr2 tex cttop("lvlFE")

}
